package t1;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

public class Serialize {
	public void serialize(List<StudentBean> studentList) throws IOException {
		File file = new File("D:\\T1\\student.txt");
		try {
			FileOutputStream fos = new FileOutputStream(file);
			for (StudentBean stu : studentList) {
				fos.write(stu.getName().getBytes());
				fos.write("\n".getBytes());
				fos.write(stu.getMajor().getBytes());
				fos.write("\n".getBytes());
			}
//			fos.write(" ".getBytes());
			fos.close();
			file = null;
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}

	}
}
